<template>
    <el-card shadow="never">
        <yun-table
                :columns="columns"
                search="nickname,mobile"
                :common-search="false"
                toolbar="refresh,add,edit,del,recyclebin,more"
                :auth="{
                    add:{:$auth->check('app\\admin\\controller\\delivery\\channel\\Goods','add')},
                    edit:{:$auth->check('app\\admin\\controller\\delivery\\channel\\Goods','edit')},
                    del:{:$auth->check('app\\admin\\controller\\delivery\\channel\\Goods','del')},
                    recyclebin:{:$auth->check('app\\admin\\controller\\delivery\\channel\\Goods','recyclebin')},
                    multi:{:$auth->check('app\\admin\\controller\\delivery\\channel\\Goods','multi')},
                }"
                :extend="extend">
        </yun-table>
    </el-card>
</template>
<script>
    import table from "@components/Table.js";
    export default{
        components:{
            'YunTable':table
        },
        data:{
            extend:{
                index_url: 'delivery/channel-goods/index',
                add_url: 'delivery/channel-goods/add',
                edit_url: 'delivery/channel-goods/edit',
                del_url: 'delivery/channel-goods/del',
                multi_url: 'delivery/channel-goods/multi',
                recyclebin_url:'delivery/channel-goods/recyclebin'
            },
            columns:[
                {checkbox: true},
                {"field":"name","title":"商品名称","operate":false},
                {"field":"goods_type","title":"商品类型",searchList: Yunqi.data.goodstype,formatter:Yunqi.formatter.tag},
                {"field":"stock","title":"库存","operate":false,formatter: function (data,row){
                    if(row.goods_type=='coupon'){
                        if(row.coupon.total){
                            return row.coupon.title+' - 剩'+(row.coupon.total-row.coupon.send)+'张';
                        }else{
                            return row.coupon.title+' - 无限张';
                        }
                    }
                    return data;
                }},
                {"field":"price","title":"单价","operate":false,formatter: function (data,row){
                    return data+'元';
                }},
                {"field":"score_price","title":"积分抵扣","operate":false,formatter: function (data,row){
                    if(!data){
                        return '不可抵扣';
                    }
                    return '每'+data+'积分抵扣1元';
                }},
                {"field":"max_score_money","title":"最高抵扣","operate":false,formatter: function (data,row){
                    if(!data){
                        return '不可抵扣';
                    }
                    return data+'元';
                }},
                {"field":"des","title":"商品简介","operate":false},
                {"field":"img","title":"商品图片","operate":false,"formatter":Yunqi.formatter.image},
                {"field":"status","title":"状态","operate":false,"searchList":{"normal":"正常","hidden":"隐藏"},"formatter":Yunqi.formatter.switch},
                {
                    field: 'operate',
                    title: __('操作'),
                    width:90,
                    action:{
                        edit:true,
                        del:true,
                    },
                }
            ]
        },
        methods: {
           
        }
    }
</script>
<style>

</style>